{% extends "index.html" %}
{% block title %}
    添加用户
{% endblock %}
{% block linkcss %}
    {{ super() }}
    <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">
{% endblock %}
{% block page_nav %}
	<li>用户</li>
	<li>修改密码</li>
{% endblock %}
{#页面内容#}
{% block content %}
    <div class="row">
        <div class="col-md-4 col-md-offset-4">
            <div class="card">
                <div class="row">
                    <div class="col-md-10 col-md-offset-1">
                        <div class="card-title">
                            <h3>修改密码</h3>
                        </div>
                        <form class="form-group" method="POST" action="{{ url_for('view.user_pwd_change') }}" id="form_pwd_change">
                            <label class="sr-only" for="old_password">旧密码</label>
                            <div class="form-group col-md-12">
                                <input type="text" id="old_password" class="form-control text-center" placeholder="旧密码" required
                                   autofocus name="old_password">
                            </div>
                            <label class="sr-only" for="new_password_1">新密码</label>
                            <div class="form-group col-md-12">
                                <input type="text" id="new_password_1" class="form-control text-center" placeholder="新密码" required
                                   autofocus name="new_password_1">
                            </div>
                            <label class="sr-only" for="new_password_2">新密码确认</label>
                            <div class="form-group col-md-12">
                                <input type="text" id="new_password_2" class="form-control text-center" placeholder="新密码确认" required
                                   autofocus name="new_password_2">
                            </div>
                            <div class="card-footer">
                                <div class="col-md-3 col-md-offset-2">
                                    <button class="btn btn-primary btn-block submit_bn" type="button" id="btn_submit">提交</button>
                                </div>
                                <div class="col-md-3 col-md-offset-2">
                                    <a class="btn btn-primary btn-block" type="button" href="{{ url_for('view.index') }}">取消</a>
                                </div>
                            </div>
                            <div class="col-md-12">
                                {% if messages %}
                                    <div class="alert alert-warning">
                                        {% for message in messages %}
                                            {% for key in messages[message] %}
                                                <p><strong class="text-center">{{ key }}</strong></p>
                                            {% endfor %}
                                        {% endfor %}
                                    </div>
                                {% endif %}
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
{% endblock %}
{% block script %}
    {{ super() }}
    <script type="text/javascript" src="{{ url_for('static', filename='js/alert.js') }}"></script>
    <script type="text/javascript">
    $("#btn_submit").click(function () {
        if ($('#new_password_1').val() != $('#new_password_2').val()) {
            ShowFailure('两次输入新密码不一致');
        }
        else {
            $('#form_pwd_change').submit();
        }
    });
    </script>
{% endblock %}

